Solving 10385 - Duathlon (Ternary search)
[andmenj-acm.git] / 10260 - Soundex / 10260.cpp
blob6432a350952c97f0abc2a5f6bfb081b1b5fe900e
1 #include <iostream>
2 #include <map>
3 #include <sstream>
5 using namespace std;
7 map<string, char> d;
9 int main(int argc, char const *argv){
10 d["AEIOUHWY"] = '0';
11 d["BFPV"] = '1';
12 d["CGJKQSXZ"] = '2';
13 d["DT"] = '3';
14 d["L"] = '4';
15 d["MN"] = '5';
16 d["R"] = '6';
17 string s;
18 while (getline(cin, s)){
19 string r = "";
20 int j = 0;
21 for (int j = 0; j < s.size(); ++j){
22 for (map<string, char>::iterator i = d.begin(); i != d.end(); ++i){
23 if (i->first.find(s[j]) != string::npos){
24 r += i->second;
25 break;
29 for (int i=0; i<r.size()-1; ++i){
30 if (r[i] == r[i+1]){
31 r.erase(i, 1);
32 --i;
35 for (int i=0; i<r.size(); ++i){
36 if (r[i] != '0'){
37 cout << r[i];
40 cout << endl;
42 return 0;